#ifndef MENUTRIGGERACTION_H
#define MENUTRIGGERACTION_H

#include <QAction>

#include <QTableWidget>
#include <functional>

typedef std::function<void(QTableWidgetItem*)> menu_trigger_action_callback;

class MenuTriggerAction : public QAction
{
public:
    explicit MenuTriggerAction(QObject *parent = nullptr);
    explicit MenuTriggerAction(const QString &text, QObject *parent = nullptr);
    explicit MenuTriggerAction(const QIcon &icon, const QString &text, QObject *parent = nullptr);

    menu_trigger_action_callback callback() const;
    void setCallback(const menu_trigger_action_callback &newCallback);

    QTableWidget *tableWidget() const;
    void setTableWidget(QTableWidget *newTableWidget);

    void setTableWidgetCallback(QTableWidget *newTableWidget, const menu_trigger_action_callback &newCallback);

    std::function<void ()> simpleCallback() const;
    void setSimpleCallback(const std::function<void ()> &newSimpleCallback);

private:
    QTableWidget *m_tableWidget;
    menu_trigger_action_callback m_callback;

    bool m_isSimple;
    std::function<void()> m_simpleCallback;
};

#endif // MENUTRIGGERACTION_H
